package com.richinfo.proxy.demo.impl;

import com.richinfo.proxy.demo.Subject;

/**
 * 代理对象
 * 
 * Created by WangXJ
 * 2019-07-04 10:58
 */
public class ProxySubject implements Subject {
	
	private RealSubject realSubject;
	
	public ProxySubject(RealSubject realSubject) {
		this.realSubject = realSubject;
	}

	@Override
	public void request() {
		System.out.println("ProxySubject ..before");
		
		realSubject.request();
		
		System.out.println("ProxySubject ..after");
	}

	// 静态代理模式，被代理的对象(真实对象)每增加一个方法
	// 代理对象相应的也要添加一个方法，很麻烦
	@Override
	public void hello() {
		System.out.println("ProxySubject ..before");
		
		realSubject.hello();
		
		System.out.println("ProxySubject ..after");
	}

}
